<?php 
	include("includes/session.php");
	include("includes/connect_db.php"); 
	include("includes/header.php");
	include("notif.php");

	$id = $_GET['id'];
	$sql_cari_data = "SELECT * FROM tb_master_karakter WHERE id_karakter = '$id'";
	$query_cari_data = mysql_query($sql_cari_data);
	$cari_data = mysql_fetch_array($query_cari_data);
?>

<style>
	.btn{
		width: 100px;
	}
</style>

<div class="span9">  
    <h3>SMS</h3>                      
    <ul class="breadcrumb well">
        <li><a href="karakter.php">Master Karakter</a> <span class="divider">/</span></li>
        <li class="active">Tambah</li>                
    </ul>    
    
    <form class="form-horizontal" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    	<div>
    		<div>
    			<div class="alert alert-info">
					Edit Karakter
			    </div>
				<div class="control-group">
					<label class="control-label">Karakter</label>
					<div class="controls">
						<input placeholder="Masukkan Karakter Baru" type="text" name="karakter" class="karakter" value="<?php echo $cari_data['karakter']; ?>">
						<input type="hidden" name="id" value="<?php echo $id; ?>">
					</div>
				</div>
    		</div>
    	</div>
		<div>
			<div class="span12">
				<ul class="breadcrumb well">
					<button type="submit" class="btn btn-info" name="simpan">
						<i class="icon-white icon-ok"></i>
						Simpan
					</button>
				</ul>
			</div>
		</div>
	</form>
    
</div><!--/span-->

<?php 
	if (isset($_POST['simpan'])) {
		$karakter = $_POST['karakter'];
		$id = $_POST['id'];

		$sql_simpan = "UPDATE tb_master_karakter SET karakter='$karakter' WHERE id_karakter='$id'";
		if ($query_simpan = mysql_query($sql_simpan)) {
			echo "<script> location.href='karakter.php'; </script>";
		}
	}
?>

<?php include("includes/footer.php"); ?>

<script type="text/javascript">
	$(document).ready(function() {
		
	});
</script>